﻿/**************************************************************
 *
 * 唯一标识：7f1534a5-3475-401c-be3c-3d9ea9d1f8a7
 * 命名空间：Sgr.Oss.Services
 * 创建时间：2023/8/25 17:31:02
 * 机器名称：DESKTOP-S0D075D
 * 创建者：antho
 * 电子邮箱：fengqinhua2016@163.com
 * 描述：
 *
 **************************************************************/

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;

namespace Sgr.Oss.Services
{
    public static class OssServiceExtensions
    {
        private const string ImageBucketName = "picture";

        public static Task<bool> PutImageAsync(
            this IOssService ossService,
            string objectName,
            Stream data,
            IDictionary<string, string>? metadata = null,
            ObjectAcl acl = ObjectAcl.Inherited,
            Action<ProgressInfo>? progress = null,
            CancellationToken cancellationToken = default)
        {
            return ossService.PutObjectAsync(ImageBucketName, objectName, data, metadata, acl, progress, cancellationToken);
        }

        public static Task<bool> RemoveImageAsync(
            this IOssService ossService,
            string objectName,
            CancellationToken cancellationToken = default)
        {
            return ossService.RemoveObjectAsync(ImageBucketName, objectName, cancellationToken);
        }
    }
}